"use strict";
const Controller = require("egg").Controller;

class UserController extends Controller {
  // 搜索用户
  async searchUser() {
    try {
      let res = await this.ctx.service.userLogin.searchUser();
      this.ctx.body = {
        code: 200,
        data: res
      };
    } catch (e) {
      this.ctx.body = {
        code: 500,
        data: {
          msg: "服务器错误"
        }
      };
    }
  }

  async userList() {
    try {
      let res = await this.ctx.service.userLogin.queryUserList();
      this.ctx.body = {
        code: 200,
        data: res
      };
    } catch (e) {
      this.ctx.body = {
        code: 500,
        data: {
          msg: "服务器错误"
        }
      };
    }
  }

  async deleteUser() {
    try {
      let res = await this.ctx.service.userLogin.deleteUserById();
      this.ctx.body = {
        code: 200,
        data: res
      };
    } catch (e) {
      this.ctx.body = {
        code: 500,
        data: {
          msg: "服务器错误"
        }
      };
    }
  }
}

module.exports = UserController;
